<%@page pageEncoding="UTF-8" %><?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<%
org.sysmo.server.SysmoServer server = (org.sysmo.server.SysmoServer)application.getAttribute("sysmoServer");
%>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />

    <link rel="stylesheet" media="screen,projection" type="text/css" href="css/reset.css" />
    <link rel="stylesheet" media="screen,projection" type="text/css" href="css/main.css" />
    <!--[if lte IE 6]><link rel="stylesheet" type="text/css" href="css/main-msie.css" /><![endif]-->
    <link rel="stylesheet" media="screen,projection" type="text/css" href="css/style.css" />
    <%--<link rel="stylesheet" media="print" type="text/css" href="css/print.css" />--%>

    <title>用户管理 - sysmo</title>
    <script src="js/lightbox.js" type="text/javascript"></script>
    <script type="text/javascript">
        <!--
        var userBox;
        var editID = 0;

        function deleteUser(id, name) {
            if (confirm("确实要删除用户 " + name + " 吗？")) {
                window.location = "DeleteUser.do?uid=" + id;
            }
        }

        function afterShowNew() {
            $("username").focus();
        }
        
        function editUser(id) {
            editID = id;
            $("userRow").style.display = "none";
            $("lightBoxTitle").innerHTML = "修改密码";
            $("oldPasswordRow").style.display = "";
            $("uid").value = id;
            userBox.Show();
            $("oldpassword").focus();
        }
        
        function onCloseNewUser() {
            editID = 0;
            $("lightBoxTitle").innerHTML = "新增用户";
            $("userRow").style.display = "";
            $("username").value = "";
            $("oldpassword").value = "";
            $("oldPasswordRow").style.display = "none";
            $("password").value = "";
            $("password2").value = "";
            $("uid").value = "0";
        }

        function onUserSubmit() {
            var check = true;
            if (editID == 0) {
                if ($("username").value == "") {
                    alert("请输入用户名");
                    $("username").focus();
                    check = false;
                }
            } else if ($("oldpassword").value == "") {
                alert("请输入旧密码");
                $("oldpassword").focus();
                check = false;
            }
            if (check) {
                if ($("password").value == "") {
                    alert("请输入新密码");
                    $("password").focus();
                    check = false;
                } else if ($("password").value != $("password2").value) {
                    alert("两次密码不匹配，请重新输入");
                    $("password2").focus();
                    check = false;
                }
            }
            return check;
        }

        <%
        if (request.getAttribute("error") != null) {
        %>
            alert("<%= org.sysmo.server.util.UtilHelper.encodeJSString((String)request.getAttribute("error")) %>");
        <%
        }
        %>
        -->
    </script>
</head>

<body>

<div id="main">

    <!-- Header -->
    <div id="header">
    
        <p id="logo">sysmo</p>
        
        <div id="slogan">A distributed system monitor tool</div>
    
    </div> <!-- /header -->
    
    <hr class="noscreen" />
    
    <!-- Navigation -->
    <div id="nav" class="box">
    
        <ul>
            <li class=""><a href="AllNodes.do">监控列表</a></li>
            <li class=""><a href="NewNodes.do">新增客户端</a></li>
            <li class="active"><a href="Users.do">用户管理</a></li>
            <li class=""><a href="Logout.do">退出登录(<%= ((org.sysmo.server.user.User)session.getAttribute("user")).getName() %>)</a></li>
        </ul>
    
    </div> <!-- /nav -->
    
    <hr class="noscreen" />
    
    <!-- Columns -->
    <div id="cols">
        <div id="cols-in" class="box">
    
            <!-- Content -->
            <div id="content">
                
                <h2 class="title-01">用户管理</h2>
                
                <div class="in">
                
                    <!-- Topstory -->
                    <div class="box">
                        <div id="topstory-txt">
                            <p><a href="#" id="addUser">增加新用户</a></p>
                            <table class="main_table">
                            <%
                            org.sysmo.server.user.User currentUser = (org.sysmo.server.user.User)session.getAttribute("user");
                            java.util.List<org.sysmo.server.user.User> users = currentUser.getAllUsers();
                            for (org.sysmo.server.user.User user : users) {
                            %>
                                <tr>
                                    <td><%= user.getName() %></td>
                                    <td><a href="javascript:editUser(<%= user.getID() %>)">修改密码</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:deleteUser(<%= user.getID() %>, '<%= org.sysmo.server.util.UtilHelper.encodeJSString(user.getName()) %>')">删除</a></td>
                                </tr>
                            <%
                            }
                            %>
                            </table>
                            <p>所有用户数：<%= users.size() %></p>
                        </div> <!-- /topstory-txt -->
                        
                    </div> <!-- /box -->
                
                </div> <!-- /in -->
                
            </div> <!-- /content -->

            <hr class="noscreen" />

            <!-- Aside -->
            <div id="aside">

                <h4 class="title-03">操作流程</h4>
                
                <div class="in">
                    <ul id="subnav">
                        <li><a href="#">部署客户端程序和配置文件</a></li>
                        <li><a href="NewNodes.do">单击此处将新客户端加入监控列表</a></li>
                        <li><a href="#">创建监控项、图表项和监控值</a></li>
                        <li><a href="#">配置监控项、上传数据采集程序</a></li>
                        <li><a href="#">查看图表，获取最新数据</a></li>
                        <%--<li><a href="#">Lorem ipsum sit amet</a></li>
                        <li><a href="#">Lorem ipsum sit amet</a></li>
                        <li class="active"><a href="#">Lorem ipsum sit amet</a></li>
                        <li><a href="#">Lorem ipsum sit amet</a></li>
                        <li><a href="#">Lorem ipsum sit amet</a></li>
                        <li class="last"><a href="#">Lorem ipsum sit amet</a></li>--%>
                    </ul>

                </div> <!-- /in -->

            </div> <!-- /aside -->
            
        </div> <!-- /cols-in -->
    </div> <!-- /cols -->

    <hr class="noscreen" />
    
    <!-- Footer -->
    <div id="footer" class="box">
        
        <p class="f-left"><a href="http://sysmo.googlecode.com">sysmo @ GoogleCode</a></p>

    </div> <!-- /box -->

</div> <!-- /main -->


<dl id="lightBox">
    <dt id="lightBoxTitle">新增用户</dt>
    <dd id="lightBoxText">
        <html:form action="AddUser.do" method="post" onsubmit="javascript:return onUserSubmit()">
            <table>
                <tr id="userRow">
                    <td class="input-table-col">用户名</td><td><html:text property="username" styleId="username" styleClass="topstory-text" /></td>
                </tr>
                <tr id="oldPasswordRow" style="display:none;">
                    <td class="input-table-col">旧密码</td><td><html:password property="oldpassword" styleId="oldpassword" styleClass="topstory-text" /></td>
                </tr>
                <tr>
                    <td class="input-table-col">新密码</td><td><html:password property="password" styleId="password" styleClass="topstory-text" /></td>
                </tr>
                <tr>
                    <td class="input-table-col">重复密码</td><td><html:password property="password2" styleId="password2" styleClass="topstory-text" /></td>
                </tr>
                <tr>
                    <td colspan="2" class="submit-button-col"><html:hidden property="uid" value="0" styleId="uid" /><html:submit value="确定" /><html:button property="button" value="取消" styleId="closeUserBox" /></td>
                </tr>
            </table>
        </html:form>
    </dd>
</dl>

<script type="text/javascript">
    userBox = initBox("lightBox", "addUser", "closeUserBox", null, afterShowNew, onCloseNewUser, null);
    <%
    if (request.getAttribute("showBox") != null) {
    %>
        userBox.Show();
    <%
    }
    %>
</script>
<!-- Do you want remove this backlinks? Look at www.nuviotemplates.com/payment.php -->
<p id="copy"><a href="http://www.nuviotemplates.com/">Free web templates</a> presented by <a href="http://www.qartin.cz/">QARTIN</a> &ndash; Our tip: <a href="http://www.thinline.cz/">Webdesign</a>, <a href="http://www.cesky-hosting.cz/">Webhosting</a></p>
<!-- Do you want remove this backlinks? Look at www.nuviotemplates.com/payment.php -->

</body>
</html>
